package com.sskj.base.http;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.base.api.Constant;
import com.sskj.base.base.HttpData;
import com.sskj.base.bean.AgreementBean;
import com.sskj.base.bean.BankTypes;
import com.sskj.base.bean.BuyDakuanListBean;
import com.sskj.base.bean.BuyGamCommonBean;
import com.sskj.base.bean.BuyPiPeiListBean;
import com.sskj.base.bean.HeaderBean;
import com.sskj.base.bean.HomeCommonBean;
import com.sskj.base.bean.JiHuoCommmonBean;
import com.sskj.base.bean.MasterUpBean;
import com.sskj.base.bean.MessageListBean;
import com.sskj.base.bean.MoneyListBean;
import com.sskj.base.bean.MyBanksBean;
import com.sskj.base.bean.NoticeBean;
import com.sskj.base.bean.OrderCommmonBean;
import com.sskj.base.bean.PaiDanCommonBean;
import com.sskj.base.bean.PiPeiStatusListBean;
import com.sskj.base.bean.QrCodeBean;
import com.sskj.base.bean.RegisterBean;
import com.sskj.base.bean.SellDaKuanListBean;
import com.sskj.base.bean.SellDetailBean;
import com.sskj.base.bean.SellPiPeiListBean;
import com.sskj.base.bean.SendListBean;
import com.sskj.base.bean.TeamCommonData;
import com.sskj.base.bean.TeamJiHuoListBean;
import com.sskj.base.bean.UpdataBean;
import com.sskj.base.bean.UploadImgBean;
import com.sskj.base.bean.UserData;

import java.io.File;
import java.util.List;

public class HttpService {

    /**
     * 登录
     */
    public PostRequest<HttpData<HeaderBean>> login(String username, String password) {
        return OkGo.<HttpData<HeaderBean>>post(Constant.SERVER_ADDRESS + "/Mobile/login/doLogin")
                .params("username", username)
                .params("password", password);
    }


    public PostRequest<HttpData> setUserData(String nickname, String realname, String remark) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/User/editData")
                .params("nickname", nickname)
                .params("username", realname)
                .params("pd_note", remark);
    }

    /**
     * 上传图片
     *
     * @param file 文件
     * @return
     */
    public PostRequest<HttpData<UploadImgBean>> uploadImg(File file) {
        return OkGo.<HttpData<UploadImgBean>>post(Constant.SERVER_ADDRESS + "/Mobile/Api/dtimageup")
                .params("field", "img")
                .params("img", file);
    }

    public PostRequest<HttpData> changeHead(String src) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/User/saveUserHeadImg")
                .params("src", src);

    }

    public GetRequest<HttpData> getCode(String mobile) {
        return OkGo.<HttpData>get(Constant.SERVER_ADDRESS + "/Mobile/Reg/sendSmsRegCode")
                .params("mobile", mobile);
    }


    /**
     * 重设交易密码
     *
     * @param pwd
     * @param code
     * @return
     */
    public PostRequest<HttpData> changePayPwd(String pwd, String code) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/User/editSecpwd")
                .params("newPass", pwd)
                .params("confirmPass", pwd)
                .params("mobileCode", code);
    }

    /**
     * 绑定支付宝
     *
     * @param name
     * @param account
     * @param code
     * @return
     */
    public PostRequest<HttpData> bandAliPay(String name, String account, String code) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Validate/validateAlipay")
                .params("zfb_name", account)
                .params("zfb_username", name)
                .params("mobileCode", code);
    }

    /**
     * 绑定微信
     *
     * @param name
     * @param imgUrl
     * @param code
     * @return
     */
    public PostRequest<HttpData> bindWeChat(String name, String wxName, String imgUrl, String code) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/validate/validateWechat")
                .params("wx_username", name)
                .params("wx_name", wxName)
                .params("wx_code", imgUrl)
                .params("mobileCode", code);
    }

    /**
     * 获取用户信息
     *
     * @return
     */
    public GetRequest<HttpData<UserData>> getUserData() {
        return OkGo.<HttpData<UserData>>get(Constant.SERVER_ADDRESS + "/Mobile/User/pub_info");

    }

    /**
     * 已添加银行卡
     *
     * @return
     */
    public GetRequest<HttpData<MyBanksBean>> getBankList() {
        return OkGo.<HttpData<MyBanksBean>>get(Constant.SERVER_ADDRESS + "/Mobile/UserBank/bindBank");
    }


    /**
     * 可添加银行卡种类列表
     *
     * @return
     */
    public GetRequest<HttpData<List<BankTypes>>> getAddBankList() {
        return OkGo.<HttpData<List<BankTypes>>>get(Constant.SERVER_ADDRESS + "/Mobile/UserBank/addBank");
    }

    /**
     * 添加银行卡
     *
     * @param bank_name
     * @param bank_account
     * @param bankId
     * @param bank_address
     * @param mobileCode
     * @return
     */
    public PostRequest<HttpData> bindBank(String bank_name, String bank_account, String bankId, String bank_address, String mobileCode) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/UserBank/addBank")
                .params("bank_name", bank_name)
                .params("bank_account", bank_account)
                .params("opening_id", bankId)
                .params("bank_address", bank_address)
                .params("mobileCode", mobileCode);
    }

    /**
     * 删除银行卡
     *
     * @param opening_id
     * @return
     */
    public PostRequest<HttpData> deleteBank(String opening_id) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/UserBank/delBank")
                .params("id", opening_id);
    }

    /**
     * 设置默认银行卡
     *
     * @param opening_id
     * @return
     */
    public PostRequest<HttpData> setBankDefault(String opening_id) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/UserBank/setDefaultBank")
                .params("id", opening_id);
    }

    /**
     * 编辑银行卡
     *
     * @param bank_name
     * @param bank_account
     * @param bankId
     * @param bank_address
     * @param mobileCode
     * @param mobile
     * @return
     */
    public PostRequest<HttpData> editBank(String bank_name, String bank_account, String bankId, String bank_address, String mobileCode, String mobile) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/UserBank/editBank")
                .params("bank_name", bank_name)
                .params("bank_account", bank_account)
                .params("id", bankId)
                .params("bank_address", bank_address)
                .params("mobile", mobile)
                .params("mobileCode", mobileCode);
    }

    /**
     * 重设登录密码
     *
     * @param newPwd
     * @param mobileCode
     * @return
     */
    public PostRequest<HttpData> resetPwd(String newPwd, String mobileCode) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/User/editPassword")
                .params("newPass", newPwd)
                .params("confirmPass", newPwd)
                .params("mobileCode", mobileCode);
    }

    public GetRequest<HttpData<MessageListBean>> getMessage(int page) {
        return OkGo.<HttpData<MessageListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Message/messageIndex")
                .params("p", page);
    }

    public GetRequest<HttpData> deleteAllMsg() {
        return OkGo.get(Constant.SERVER_ADDRESS + "/Mobile/Message/delUserMessage");
    }

    public GetRequest<HttpData<MessageListBean.MessageBean>> getMsgDetail(String msgId) {
        return OkGo.<HttpData<MessageListBean.MessageBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Message/showUserMessageDetail")
                .params("id", msgId);
    }

    public GetRequest<HttpData<HomeCommonBean>> getHomeDate() {
        return OkGo.<HttpData<HomeCommonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdIndex");
    }

    /**
     * 社群激活
     *
     * @param mobile
     * @param code
     * @param pwd
     * @return
     */
    public PostRequest<HttpData> jiHuo(String mobile, String code, String pwd) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/activatePd")
                .params("account", mobile)
                .params("mobileCode", code)
                .params("secpwd", pwd);
    }

    /**
     * 激活码赠送
     *
     * @param mobile
     * @param account
     * @return
     */
    public PostRequest<HttpData> sendJiHuo(String mobile, String account) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/changeAdd")
                .params("to_account", mobile)
                .params("toMoney", account)
                .params("money_id", 3);
    }

    public GetRequest<HttpData> getJihuo() {
        return OkGo.<HttpData>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/changeAdd")
                .params("id", 3);
    }


    public GetRequest<HttpData<SendListBean>> getSendJiHuoList(int page) {
        return OkGo.<HttpData<SendListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/ChangeAddLog")
                .params("p", page);
    }

    public GetRequest<HttpData<SendListBean>> getSendPaiDanList(int page) {
        return OkGo.<HttpData<SendListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/moneyFourChangeLog")
                .params("p", page);
    }

    /**
     * 排单币赠送
     *
     * @param mobile
     * @param amount
     * @return
     */
    public PostRequest<HttpData> sendPaiDan(String mobile, String amount) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/moneyFourChange")
                .params("to_account", mobile)
                .params("toMoney", amount)
                .params("money_id", 4);
    }

    public GetRequest<HttpData<PaiDanCommonBean>> getCreatePaiDanMsg() {
        return OkGo.<HttpData<PaiDanCommonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/generatePdCode");


    }

    /**
     * 生成排单币
     *
     * @param amount
     * @param pwd
     * @return
     */
    public PostRequest<HttpData> createCoin(String amount, String pwd) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/generatePdCode")
                .params("num", amount)
                .params("secpwd", pwd);
    }

    /**
     * 我的排单币金额
     *
     * @return
     */
    public GetRequest<HttpData<HomeCommonBean>> getMyCoin() {
        return OkGo.<HttpData<HomeCommonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/moneyFourChange");
    }

    /**
     * 我的激活码余额
     *
     * @return
     */
    public GetRequest<HttpData<JiHuoCommmonBean>> getMyJiHuo() {
        return OkGo.<HttpData<JiHuoCommmonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/activatePd");
    }

    public GetRequest<HttpData<QrCodeBean>> getQrCode() {
        return OkGo.<HttpData<QrCodeBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Team/ztFriend");
    }

    /**
     * 卖出提交
     *
     * @param money_id
     * @param price
     * @param payment
     * @param secpwd
     * @return
     */
    public PostRequest<HttpData> sellGam(int money_id, String price, String payment, String secpwd) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/jsbzAdd")
                .params("money_id", money_id)
                .params("price", price)
                .params("payment", payment)
                .params("secpwd", secpwd);

    }

    /**
     * 卖出待匹配
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<SellPiPeiListBean>> getSellWaitPiPei(int page) {
        return OkGo.<HttpData<SellPiPeiListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdJsbzOne")
                .params("p", page);
    }

    /**
     * 卖出待打款
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<SellDaKuanListBean>> getSellWaitDaKuan(int page) {
        return OkGo.<HttpData<SellDaKuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdJsbzTwo")
                .params("p", page);
    }

    public GetRequest<HttpData<PiPeiStatusListBean>> getSellPiPeiStatus(int page, String order) {
        return OkGo.<HttpData<PiPeiStatusListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/jsbzpdList")
                .params("p", page)
                .params("jsbz_id", order);
    }

    public GetRequest<HttpData<PiPeiStatusListBean>> getBuyPiPeiStatus(int page, String order) {
        return OkGo.<HttpData<PiPeiStatusListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/tgbzpdList")
                .params("p", page)
                .params("tgbz_id", order);
    }

    public GetRequest<HttpData<PiPeiStatusListBean>> getBuyCompleteStatus(int page, String order) {
        return OkGo.<HttpData<PiPeiStatusListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/tgbzWcList")
                .params("p", page)
                .params("tgbz_id", order);
    }

    public PostRequest<HttpData> buyGam(int buyType, String payment, String secpwd) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/tgbzAdd")
                .params("amount", buyType)
                .params("payment", payment)
                .params("secpwd", secpwd)
                .params("regProtocol", 1);
    }

    /**
     * 卖出宝石匹配详情
     *
     * @param order
     * @return
     */
    public GetRequest<HttpData<SellDetailBean>> getOrderDetail(String order) {
        return OkGo.<HttpData<SellDetailBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdDetail")
                .params("id", order);
    }

    public GetRequest<HttpData<BuyGamCommonBean>> getBuyGamCommonData() {
        return OkGo.<HttpData<BuyGamCommonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/PdBuyDem");
    }

    /**
     * 买入待打款
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyDakuanListBean>> getBuyWaitDaKuan(int page) {
        return OkGo.<HttpData<BuyDakuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdTgbzTwo")
                .params("p", page);
    }


    /**
     * 社群激活记录
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<List<TeamJiHuoListBean>>> getTeamJiHuo(int page) {
        return OkGo.<HttpData<List<TeamJiHuoListBean>>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/activateList")
                .params("p", page);
    }


    /**
     * 买入待确认
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyDakuanListBean>> getBuyWaitConfirm(int page) {
        return OkGo.<HttpData<BuyDakuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdTgbzThree")
                .params("p", page);
    }


    /**
     * 卖出待确认
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyDakuanListBean>> getSellWaitConfirm(int page) {
        return OkGo.<HttpData<BuyDakuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdJsbzThree")
                .params("p", page);
    }


    /**
     * 卖出已完成
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyDakuanListBean>> getSellComplete(int page) {
        return OkGo.<HttpData<BuyDakuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdJsbzFour")
                .params("p", page);
    }


    /**
     * 买入已完成
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyDakuanListBean>> getBuyComplete(int page) {
        return OkGo.<HttpData<BuyDakuanListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdTgbzFour")
                .params("p", page);
    }


    /**
     * 买入待匹配
     *
     * @param page
     * @return
     */
    public GetRequest<HttpData<BuyPiPeiListBean>> getBuyWaitPiPei(int page) {
        return OkGo.<HttpData<BuyPiPeiListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdTgbzOne")
                .params("p", page);
    }

    /**
     * 出售宝石留言
     *
     * @param toUserId
     * @param content
     * @return
     */
    public PostRequest<HttpData> sellLeaveMsg(String toUserId, String content) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/pdMessage")
                .params("id", toUserId)
                .params("content", content);
    }

    /**
     * 卖家确认付款
     *
     * @param orderId
     * @param payImg
     * @return
     */
    public PostRequest<HttpData> confirmBuyPay(String orderId, String payImg) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/tgbzDkAdd")
                .params("id", orderId)
                .params("pay_img", payImg);
    }

    public PostRequest<HttpData> uploadJia(String order, String payImg) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/tousu")
                .params("id", order)
                .params("img", payImg);
    }

    public PostRequest<HttpData> confirmShowQian(String order) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/confirmPay")
                .params("id", order);
    }

    /**
     * 订单未读数据
     *
     * @return
     */
    public GetRequest<HttpData<OrderCommmonBean>> getOrderCommmonData() {
        return OkGo.<HttpData<OrderCommmonBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/pub_info");
    }

    public PostRequest<HttpData> sendMessage(String message) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Message/sendMessage")
                .params("content", message);
    }

    public GetRequest<HttpData<TeamCommonData>> getTeamCommonData(int page) {
        return OkGo.<HttpData<TeamCommonData>>get(Constant.SERVER_ADDRESS + "/Mobile/Team/ztIndex")
                .params("p", page);
    }

    public GetRequest<HttpData<MoneyListBean>> getMoneyHistoryData(String mid, int page) {
        return OkGo.<HttpData<MoneyListBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Money/moneyLog")
                .params("mid", mid)
                .params("p", page);
    }

//    Observable<HttpResponse<String>> register(@Field("mobile") String mobile,
//                                              @Field("mobileCode") String mobileCode,
//                                              @Field("password") String password,
//                                              @Field("secpwd") String secpwd,
//                                              @Field("regprotocol") int regprotocol);

    public PostRequest<HttpData> register(String mobile, String mobileCode, String passWord, String secpwd, int i) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/reg/index")
                .params("mobile", mobile)
                .params("mobileCode", mobileCode)
                .params("password", passWord)
                .params("secpwd", secpwd)
                .params("regprotocol", i);
    }

    public GetRequest<HttpData<AgreementBean>> getAgreement() {
        return OkGo.<HttpData<AgreementBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Reg/regProtocol");
    }

    public GetRequest<HttpData<RegisterBean>> getIsNeedSMS() {
        return OkGo.<HttpData<RegisterBean>>get(Constant.SERVER_ADDRESS + "mobile/Api/cms_check");
    }

    public PostRequest<HttpData> forgetPwd(String mobile, String code, String pwd) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/forgot/forgotByMobile")
                .params("account", mobile)
                .params("mobileCode", code)
                .params("new_pass", pwd)
                .params("confirm_new_pass", pwd);
    }

    public PostRequest<HttpData<UpdataBean>> updata(String verName) {
        return OkGo.<HttpData<UpdataBean>>post(Constant.SERVER_ADDRESS + "Mobile/api/version_check")
                .params("version", verName)
                .params("type", 1);
    }

    public GetRequest<HttpData<MasterUpBean>> getOrderMoneys() {
        return OkGo.<HttpData<MasterUpBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Pd/masterUpInfo");
    }

    /**
     * 主单升级提交
     *
     * @param price
     * @return
     */
    public PostRequest<HttpData> masterChange(String price) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/masterChange")
                .params("price", price);
    }

    /**
     * 福利单降级提交
     *
     * @param type
     * @return
     */
    public PostRequest<HttpData> branchChange(int type) {
        return OkGo.<HttpData>post(Constant.SERVER_ADDRESS + "/Mobile/Pd/branchChange")
                .params("type", type);
    }

    public GetRequest<HttpData<NoticeBean>> getNotice() {
        return OkGo.<HttpData<NoticeBean>>get(Constant.SERVER_ADDRESS + "/Mobile/Api/appBomb");
    }
}
